//
//  AppNetworkingManager+OASubmit.m
//  OANetworkManager_Example
//
//  Created by TFAppleWork-Summer on 2018/3/2.
//  Copyright © 2018年 GuoRui. All rights reserved.
//

#import "AppNetworkingManager+OASubmit.h"
#import <YYModel/YYModel.h>
#import "OADailyReportDetailModel.h"
#import "OAOvertimeReportCommitModel.h"
#import "OAOvertimeReportDetailModel.h"
#import "OALeaveTypeModel.h"
#import "OALeaveReportCommitModel.h"
#import "OALeaveReportDetailModel.h"

@implementation AppNetworkingManager (OASubmit)
+(TFRequest *)addOrUpdateJournalWithModel:(OADailyReportDetailModel *)detailModel complete:(OANetworkingObjectBlock)complete{
    
    NSDictionary *param = @{@"obj" : [detailModel yy_modelToJSONString]};
    
    return [self startRequestWithParams:param
                                   path:@"journal/addOrUpdate"
                     responseObjectPath:@"data"
                  popoverProgressString:nil
               handleErrorAutomatically:OANETWORKMANAGERSHOWHUD
                          responseBlock:^(id response, NSError *error) {
                              
                              OADailyReportDetailModel *detailModel = [OADailyReportDetailModel modelWithDict:response];
                              complete(detailModel,error);
                          }];
    
    
}

+(TFRequest *)addOrUpdateOverTimeWithModel:(OAOvertimeReportCommitModel *)overTimeModel complete:(OANetworkingObjectBlock)complete{
    
    NSDictionary *param = @{@"obj" : [overTimeModel yy_modelToJSONString]};
    
    return [self startRequestWithParams:param
                                   path:@"overtime/addOrUpdate"
                     responseObjectPath:@"data"
                  popoverProgressString:nil
               handleErrorAutomatically:OANETWORKMANAGERSHOWHUD
                          responseBlock:^(id response, NSError *error) {
                              OAOvertimeReportDetailModel *overTimeDetailModel = [OAOvertimeReportDetailModel modelWithDict:response];
                              complete(overTimeDetailModel,error);
                          }];
}

+(TFRequest *)getLeaveTypeComplete:(OANetworkingObjectBlock)complete{
    
    return [self startRequestWithParams:nil
                                   path:@"leave/getLeaveType"
                     responseObjectPath:@"data"
                  popoverProgressString:nil
               handleErrorAutomatically:OANETWORKMANAGERSHOWHUD
                          responseBlock:^(id response, NSError *error) {
                              
                              NSArray *leaveTypeModels =[OALeaveTypeModel modelWithArray:response];
                              complete(leaveTypeModels,error);
                          
                          }];
}
+(TFRequest *)addOrUpdateLeaveWithModel:(OALeaveReportCommitModel *) model
                              Complete:(OANetworkingObjectBlock)complete{
 
    NSDictionary *params = @{@"obj" : [model yy_modelToJSONString]};
    
    return [self startRequestWithParams:params
                                   path:@"leave/addOrUpdate"
                     responseObjectPath:@"data"
                  popoverProgressString:nil
               handleErrorAutomatically:OANETWORKMANAGERSHOWHUD
                          responseBlock:^(id response, NSError *error) {
                              OALeaveReportDetailModel *detailModel = [OALeaveReportDetailModel modelWithDict:response];
                              complete(detailModel,error);
                          }];
}



@end
